﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_Default.Master" AutoEventWireup="true" CodeBehind="Artists.aspx.cs" Inherits="WebApplication.Artists" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%--标签--%>
    <div class="search-card">
    </div>

    <%--内容--%>
    <div class="layui-row mt-20 mb-10">

        <% if (users.Count > 0)
            { %>

        <% foreach (Models.User user in users)
            { %>

        <div class="layui-col-md12">
            <div class="artist-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md2">
                        <div class="artist-header">
                            <a href="User/Arts.aspx?id=<%=user.UserID %>" target="_blank">
                                <div class="avatar-wrapper">
                                    <span class="avatar"
                                        style="width: 60px; height: 60px; cursor: pointer;">
                                        <img
                                            src="<%=user.UserInfo.AvatarUrl.Substring(1) %>" /></span><span
                                                class="alias"></span>
                                </div>
                            </a>
                            <div class="nickname">
                                <%=user.UserInfo.NickName %>
                                <i class="iconfont <%=user.UserInfo.Sex == 1 ? "icon-nv" : user.UserInfo.Sex == 2 ? "icon-nan" : "" %>" style="font-size: 16px;"></i>
                            </div>
                            <div class="lm">
                                <div class="lmid"><span class="prefix">联盟ID</span><span class="id"><%=user.UserID %></span></div>
                            </div>
                            <a class="layui-btn layui-btn-danger-2" href="Resume.aspx?id=<%=user.UserID %>" target="_blank">约稿
                            </a>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <div class="tags">
                            <% 
                                if (user.ResumeInfo.IdentityTag != null && user.ResumeInfo.IdentityTag != "")
                                {
                            %>
                            <span class="el-tag el-tag--mini el-tag--light"><%=user.ResumeInfo.IdentityTag %></span>
                            <%} %>

                            <% 
                                string tag = user.ResumeInfo.Tag;
                                List<string> tags = new List<string>();
                                if (tag != null)
                                {
                                    tags = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(tag);
                                }
                                if (tags.Count > 0)
                                {
                                    tags.Remove("@");
                                }

                                foreach (string t in tags)
                                {
                            %>
                            <span class="el-tag el-tag--info el-tag--mini el-tag--light"><%=t %></span>
                            <%} %>
                        </div>
                        <div class="intro">
                            <div class="resume-info">
                                <span class="label">简介：</span>
                                <div class="content"><%=(user.ResumeInfo.Intro == null || user.ResumeInfo.Intro == "") ? "未填写" : user.ResumeInfo.Intro %></div>
                            </div>
                            <div class="resume-info">
                                <span class="label">经验：</span>
                                <div class="content"><%=(user.ResumeInfo.Experience == null || user.ResumeInfo.Experience == "") ? "未填写" : user.ResumeInfo.Experience %></div>
                            </div>
                            <div class="resume-info">
                                <span class="label">联系：</span>
                                <div class="content"><%=(user.ResumeInfo.Contact == null || user.ResumeInfo.Contact == "") ? "未填写" : user.ResumeInfo.Contact %></div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-row layui-col-space10">

                            <% if (user.Artworks.Count > 0)
                                { %>
                            <% foreach (Models.Artworks artwork in user.Artworks.Take(4))
                                { %>
                            <div class="layui-col-sm3" style="float: right;">
                                <div class="art-item">
                                    <a style="display: block;" href="../Art/Detail.aspx?id=<%=artwork.ArtworkID %>" target="_blank">
                                        <div class="cover-wrapper"
                                            style="background-image: url(<%=artwork.Cover.Substring(1)%>); height: 200px;">
                                        </div>
                                    </a>
                                </div>
                            </div>
                            <%} %>
                            <%}
                                else
                                { %>
                            <div style="height: 207px; display: flex; align-items: center; justify-content: center;">
                                暂无作品
                            </div>
                            <%} %>
                        </div>
                    </div>

                </div>
            </div>
        </div>

        <%} %>
        <%}
            else
            { %>
        <div class="empty"></div>
        <%} %>
    </div>


    <%--分页--%>
    <div class="text-center" id="laypage"></div>


    <script>
        const data = [
            {
                name: '类型',
                value: 'type',
                children: [
                    {
                        name: '全部',
                        value: ''
                    }
                ].concat(tagOptions.types.map(item => { return { name: item, value: item } }))
            },
            {
                name: '风格',
                value: 'style',
                children: [
                    {
                        name: '全部',
                        value: ''
                    }
                ].concat(tagOptions.styles.map(item => { return { name: item, value: item } }))
            }
        ]

        utils.searchTags({
            data,
            elem: '.search-card',
            click: (opt) => {
                let url = new URL(location.href);
                url.searchParams.set(opt.name, opt.value);
                location.href = url;
            }
        })

        layui.use('laypage', function () {
            var laypage = layui.laypage;

            //执行一个laypage实例
            laypage.render({
                elem: 'laypage' //注意，这里的 test1 是 ID，不用加 # 号
                , count: <%=totalCount%> //数据总数，从服务端得到
              , curr:<%=pageIndex%>
              , limit:<%=pageSize%>
              , jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    //console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    //console.log(obj.limit); //得到每页显示的条数

                    //首次不执行
                    if (!first) {
                        let url = new URL(location.href);
                        url.searchParams.set("pageIndex", obj.curr)
                        location.href = url;
                    }
                }
            });
        });

    </script>
</asp:Content>
